/*============================================================================*/
/*                                                                            */
/*  FILE       : comp_def.h                                                   */
/*  CONTENTS   : Contains compiler defines and macros.                        */
/*               Defines __TARGET__ based upon the compiler being used.       */
/*               __TARGET__ indicates whether the code is being compiled to   */
/*               run on the Motion Control Card or a PC.                      */
/*----------------------------------------------------------------------------*/
/*    $Archive:: /Software/mbapi/release/include/dprio/COMP_DEF.H            $*/
/*   $Revision:: 337                                                         $*/
/*----------------------------------------------------------------------------*/
/*  VISIBILITY : Public                                                       */
/*               Copyright (c) 1997, 1998, 1999 Motionbase PLC                */
/*               All rights reserved.                                         */
/*----------------------------------------------------------------------------*/
/*  HISTORY    :                                                              */
/*                                                                            */
/*    Date     Author    Description                                          */
/*  08/10/97     KG      Converted to Motionbase format.                      */
/*  02/03/98     KG      Renamed comp_def.h.                                  */
/*                       Added __TARGET__.                                    */
/*  20/05/98     KG      Removed _splitpath #define.                          */
/*  19/05/99     KG      16-bit Windows support removed.                      */
/*                       CCONV changed for DLL.                               */ 
/*                       __NEXTMOVE__ replaced by __MCC__                     */
/*============================================================================*/
#ifndef _COMP_DEF_H_
#define _COMP_DEF_H_

/*----------------------------------------------------------------------------*/
/* Define hardware platforms                                                  */
/*----------------------------------------------------------------------------*/
#define __PC__   1                     /* Code is being built for PC          */
#define __MCC__  2                     /* Code is being built for MCC         */
/*----------------------------------------------------------------------------*/
/* Define __TARGET__ based upon compiler used                                 */
/*----------------------------------------------------------------------------*/
#undef  __TARGET__
/*----------------------------------------------------------------------------*/
/* If using Texas compiler code is destined to run on Motion Control Card.    */
/*----------------------------------------------------------------------------*/
#if _TMS320C30 || _TMS320C40
  #define __TARGET__ __MCC__
#endif
/*----------------------------------------------------------------------------*/
/* If using Borland compiler code is destined to run on PC                    */
/*----------------------------------------------------------------------------*/
#if __BORLANDC__
  #define __TARGET__ __PC__
#endif
/*----------------------------------------------------------------------------*/
/* If using Microsoft compiler code is destined to run on PC                  */
/*----------------------------------------------------------------------------*/
#if _MSC_VER
  #define __TARGET__ __PC__
#endif
/*----------------------------------------------------------------------------*/
/* Compiler not supported                                                     */
/*----------------------------------------------------------------------------*/
#ifndef __TARGET__
  #error __TARGET__ not defined - compiler not supported
#endif

/*----------------------------------------------------------------------------*/
/* Conversions for Microsoft from Borland                                     */
/*----------------------------------------------------------------------------*/
#ifdef _MSC_VER
  /*--------------------------------------------------------------------------*/
  /* Only support VC++ 5.0 (defined as 1100)                                  */
  /*--------------------------------------------------------------------------*/
  #if _MSC_VER == 1100
    #error This Microsoft compiler not supported
  #endif
  /*--------------------------------------------------------------------------*/
  /* Macros that allow code written in Borland to be compiled with Microsoft  */
  /* VC++ 5.0.                                                                */
  /*--------------------------------------------------------------------------*/
  #define inport    _inpw
  #define outport   _outpw
  #define inportb   _inp
  #define outportb  _outp
  #define getvect   _dos_getvect
  #define setvect   _dos_setvect
  #define fnsplit   _splitpath
  #define fnmerge   _makepath
  #define MAXDRIVE  _MAX_DRIVE
  #define MAXDIR    _MAX_DIR
  #define MAXFILE   _MAX_FNAME
  #define MAXEXT    _MAX_EXT
  #define MK_FP     _MK_FP
  #define interrupt
  /*--------------------------------------------------------------------------*/
  /* Borland defines __WIN32__ for 32 bit console and GUI applications.       */
  /* VC++ 5.0 uses _WIN32 and is always defined.                              */
  /*--------------------------------------------------------------------------*/
  #define __WIN32__ _WIN32
  /*--------------------------------------------------------------------------*/
  /* Borland defines __DLL__ when building a DLL and __MT__ when multi-       */
  /* threaded.  VC++ 5.0 defines a single macro _DLL.                         */
  /*--------------------------------------------------------------------------*/
  #ifdef _DLL
    #define __DLL__
    #define __MT__
  #endif
  /*--------------------------------------------------------------------------*/
  /* The __stdcall calling convention is used to call Win32 API functions.    */
  /* The callee cleans the stack, so the compiler makes vararg functions      */
  /* __cdecl. Functions that use this calling convention require a function   */
  /* prototype.                                                               */
  /*--------------------------------------------------------------------------*/
  #define _stdcall __stdcall
  /*--------------------------------------------------------------------------*/
  /* Far modifiers are redundant in 32 bit applications                       */
  /*--------------------------------------------------------------------------*/
  #define far
  #define _far
  #define __far
  #define FAR far
  /*--------------------------------------------------------------------------*/
  /* Borland defines _Windows for 16 and 32-bit compilations                  */
  /*--------------------------------------------------------------------------*/
  #define _Windows
  /*--------------------------------------------------------------------------*/
  /* Borland uses these modifiers to export classes, functions, and data.     */
  /* The linker enters functions flagged with _export or __export  into an    */
  /* export table for the module.                                             */
  /* Using _export or __export eliminates the need for an EXPORTS section in  */
  /* your module definition file.                                             */
  /* It is undefined in VC++.                                                 */
  /*--------------------------------------------------------------------------*/
  #define _export
  #define __export
  /*--------------------------------------------------------------------------*/
  /* Microsoft uses strcpy for fstrcpy                                        */
  /*--------------------------------------------------------------------------*/
  #define _fstrcpy strcpy
#endif

/*----------------------------------------------------------------------------*/
/* Conversions for Borland from VC++.                                         */
/*----------------------------------------------------------------------------*/
#ifdef __BORLANDC__
  /*--------------------------------------------------------------------------*/
  /* Only support Borland C++ v4.51 (defined as 0x460)                        */
  /*--------------------------------------------------------------------------*/
  #if __BORLANDC__ != 0x460
    #error This Borland compiler not supported
  #endif
  /*--------------------------------------------------------------------------*/
  /* Macros that allow code written in Borland to be compiled with Microsoft  */
  /* VC++ 5.0.                                                                */
  /*--------------------------------------------------------------------------*/
  #define _inpw        inport
  #define _outpw       outport
  #define _inp         inportb
  #define _outp        outportb
  #define _makepath    fnmerge
  #define _MK_FP       MK_FP
  #define _inline
  /*--------------------------------------------------------------------------*/
  /* Borland defines __WIN32__ for 32 bit console and GUI applications.       */
  /* VC++ 5.0 uses _WIN32 and is always defined.                              */
  /*--------------------------------------------------------------------------*/
  #ifdef __WIN32__
    #define _WIN32
  #endif
  /*--------------------------------------------------------------------------*/
  /* Borland defines __DLL__ when building a DLL and __MT__ when multi-       */
  /* threaded.  VC++ 5.0 defines a single macro _DLL.                         */
  /*--------------------------------------------------------------------------*/
  #if (defined __DLL__) && (defined __MT__)
    #define _DLL
  #endif
  /*--------------------------------------------------------------------------*/
  /* The _stdcall and __stdcall keywords force the compiler to generate       */
  /* function calls using the Standard calling convention. The resulting      */
  /* function calls are smaller and faster. Functions must pass the correct   */
  /* number and type of arguments; this is unlike normal C use, which permits */
  /* a variable number of function arguments.                                 */
  /*--------------------------------------------------------------------------*/
  #define __stdcall _stdcall
  /*--------------------------------------------------------------------------*/
  /* Microsoft defines FAR as far                                             */
  /*--------------------------------------------------------------------------*/
  #ifdef __WIN32__
    #define FAR far
  #else
    #define FAR _far
  #endif
  /*--------------------------------------------------------------------------*/
  /*--------------------------------------------------------------------------*/
  #ifdef _Windows
    #define LONG long
    #define CHAR char
    #define INT int
    #define ULONG unsigned long
    #define FLOAT float
    #define DOUBLE double
    #define VOID void
  #endif

#endif

/*----------------------------------------------------------------------------*/
/* Define types                                                               */
/*----------------------------------------------------------------------------*/
#ifndef _Windows
  #define BYTE unsigned char
  #define UINT unsigned int
  #define LONG long
  #define CHAR char
  #define INT int
  #define ULONG unsigned long
  #define FLOAT float
  #define DOUBLE double
  #define VOID void
#endif

/*----------------------------------------------------------------------------*/
/* Dual port RAM accesses are always 16-bit. Define types for these accesses. */
/* COFF files contain 8-bit data.  Define types for this data.                */
/*----------------------------------------------------------------------------*/
#ifdef _WIN32
  typedef unsigned char BITS_8;
  typedef short         BITS_16;
  typedef unsigned int  BITS_32;
#else
  typedef unsigned char BITS_8;
  typedef int           BITS_16;
  typedef unsigned long BITS_32;
#endif

/*----------------------------------------------------------------------------*/
/* PC code functions may need additional modifiers                            */
/*----------------------------------------------------------------------------*/
#if __TARGET__ == __PC__
  /*--------------------------------------------------------------------------*/
  /* Modify all library function calls to be _stdcall to generate small, fast */
  /* code under Windows.                                                      */
  /*--------------------------------------------------------------------------*/
  #ifdef _Windows
    #ifdef _WIN32
      #if defined (_DLL)
        #define CCONV __declspec(dllexport)
      #else
        #ifdef _MSC_VER
          #define CCONV __declspec(dllimport)
        #else
          #define CCONV
        #endif
      #endif
    #else
      #error 16-bit Windows applications are not supported.
    #endif
  #else
    /*------------------------------------------------------------------------*/
    /* DOS applications do not require calling convention modification        */
    /*------------------------------------------------------------------------*/
    #define CCONV
  #endif
#endif

/*----------------------------------------------------------------------------*/
/* MCC code does not require the following modifiers.                         */
/*----------------------------------------------------------------------------*/
#if __TARGET__ == __MCC__
  /*--------------------------------------------------------------------------*/
  /* The Texas compiler always uses the standard calling convention.          */
  /*--------------------------------------------------------------------------*/
  #define CCONV
  /*--------------------------------------------------------------------------*/
  /* The small memory model is always used - FAR has no meaning               */
  /*--------------------------------------------------------------------------*/
  #define FAR
  /*--------------------------------------------------------------------------*/
  /* Functions are not exported - it has no meaning                           */
  /*--------------------------------------------------------------------------*/
  #define _export
  #define __export
  /*--------------------------------------------------------------------------*/
  /* Functions are always declared using the 'C' style naming convention      */
  /*--------------------------------------------------------------------------*/
  #define _cdecl
#endif

/*----------------------------------------------------------------------------*/
/* If compiling for Windows include windows.h                                 */
/*----------------------------------------------------------------------------*/
#ifdef _Windows
  #include <windows.h>
#endif

/*----------------------------------------------------------------------------*/
/* Define boolean TRUE and FALSE                                              */
/*----------------------------------------------------------------------------*/
#define FALSE 0
#define TRUE  1

#endif /* _COMP_DEF_H_ */
/*============================================================================*/
/* END OF FILE                                                                */
/*============================================================================*/

